Flutter GetX-转场动画

2022/12/5 GetX

本文介绍Getx路由转场动画的定义和使用。

# 定义

import 'package:flutter/widgets.dart';

enum Transition {
  fade,
  fadeIn,
  rightToLeft,
  leftToRight,
  upToDown,
  downToUp,
  rightToLeftWithFade,
  leftToRightWithFade,
  zoom,
  topLevel,
  noTransition,
  cupertino,
  cupertinoDialog,
  size,
  native
}

typedef GetPageBuilder = Widget Function();

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# 示例

class AppPages {
  static const INITIAL = AppRoutes.Home;

  static final List<GetPage> routes = [

    GetPage(
      name: AppRoutes.Login, 
      page: () => const LoginView(), 
      // 定义转场动画
      transition: Transition.downToUp
    ),
  ];

  static final unknownRoute = GetPage(name: AppRoutes.Notfound, page: () => const NotFoundView());
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
最后更新时间: 2022/12/5 09:03:12